package com.gdcp.System.controller;


import com.gdcp.System.entity.Department;
import com.gdcp.System.service.DepartmentService;
import com.gdcp.handle.MyException;
import com.gdcp.response.RestCode;
import com.gdcp.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wrl
 * @since 2021-05-30
 */
@Api(value = "部门人数查询" ,tags = "部门人数查询")
@RestController
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
     private DepartmentService departmentService;
    @ApiOperation(value = "查询所有的部门人数")
    @GetMapping("/findDeptAndCount")
    public Result findDeptAndCount(){
        List<Department> deptlist = departmentService.findDeptAndCount();
        if(deptlist.size()==0){
            throw new MyException(RestCode.DEPARTMENT_NOT_EXIST.getCode(),RestCode.DEPARTMENT_NOT_EXIST.getMessage());
        }
        return Result.ok().data("deptCount",deptlist);
    }
}

